<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="yaodian100" uri="http://www.yaodian100.com/jsp/yaodian100" %>
<%@ include file="/taglibs.jsp"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<link rel="stylesheet" type="text/css" href="/css/validator.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="/css/ui.jqgrid.css" />
<link href="/css/ddaccordion.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css" media="screen">
 <!-- 
  SELECT.selCont{ margin: 10px; width: 200px; }
  -->
</style> 
<!-- 数字验证 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css"/>
<script src="/js/grid.locale-en.js" type="text/javascript"></script>
<script src="/js/jquery.jqGrid.min.js" type="text/javascript" charset="UTF-8"></script>
<s:url var="supplierPops" value="/json/supplierPops.do"/>
<s:url var="brandPops" value="/json/brandPops.do"/>
<script src="/js/ckeditor/ckeditor.js" type="text/javascript"></script>
<script type="text/javascript"> 
	var content;
	var qry_target = '01';
	function dispScmNotice(){
		var notice = CKEDITOR.instances['scmNotice'];
		if(notice){
			notice.destroy();
			CKEDITOR.remove(notice);
		}
		CKEDITOR.replace('scmNotice',{toolbar : 'product'});
		CKEDITOR.config.contentsCss='/css/yaodian100_pdpagese_v2.css';
	}
	function chk24hr(){
		if ( "${product.productType}" == 6 ){
			alert("N选M商品不可异动供应商");
		}else if ( "${product.supplierId}" == "010000" || "${product.supplierId}" == "010001" ){
			alert("台湾供应商的商品不允许更换普通供应商与台湾供应商");
		}else if ( "${product.isScm}" == "Y" ){
			alert("SCM转单商品不可异动供应商");
		}else if ( parseInt("${approveSize}",10) > 0){
			alert("申请中的供应商请等待已审核后再申请");
		}else if ( "${not empty addonsMain}" == "true" ){
			alert("搭售主商品不可异动供应商");			
		}else if ( "${not empty addons}" == "true" ){
			alert("该商品有设成搭售，请先移除搭售设定");
		}else if ( "${not empty nms}" == "true" ){
			alert("该商品有设成n选m，请先移除搭售设定");
		}else if ( "${chkHasInventory}" == "true"){
			alert("该商品尚有库存不可异动供应商");
		}else{
			$.post("${midContextPath}/product/jsonChk24Hr.do",{productId:'${product.productId}'},callback,"json");
		}
	}
	function callback(hr24Result){
		if ( null == hr24Result )
			location.href="${midContextPath}/productSupplierApprove/add.do?productId=${product.productId}";
		else
			alert(hr24Result);
		return false ;
	}	
		
 	$(function() {
	 	<c-rt:if test="${product.supplierId eq '010000' or product.supplierId eq '010001'}">
			$("#twSupplier").show();
			<c-rt:if test="${not empty product.productId and not empty product.twSupplierId}">
				$("#getTwSupplier").hide();
			</c-rt:if>
		</c-rt:if> 	 	
		<c-rt:if test="${not empty product.productId}">
	 		if ( $("#supplierIdParam").val() != ""){
			$("#supplierIdParam").attr("readonly",true);
			$("#getSupplier").hide();
		}
		</c-rt:if>
		<c-rt:choose>
			<c-rt:when test="${not empty product.productId and product.isScm eq 'Y'}">
				$("#showScmNotice").show();
				dispScmNotice();
			</c-rt:when>
			<c-rt:otherwise>
				var notice = CKEDITOR.instances['scmNotice'];
				if(notice){
					notice.destroy();
					CKEDITOR.remove(notice);
				}
				$("#showScmNotice").hide();
			</c-rt:otherwise>
		</c-rt:choose>
		
		<c-rt:if test="${empty product.productId}">
		$("#isScmY").click(function() {
			$("#showScmNotice").show();
			dispScmNotice();
		});	 
		$("#isScmN").click(function() {
			var notice = CKEDITOR.instances['scmNotice'];
			if(notice){
				notice.destroy();
				CKEDITOR.remove(notice);
			}
			$("#showScmNotice").hide();
		});	
		$("#isScmB").click(function() {
			var notice = CKEDITOR.instances['scmNotice'];
			if(notice){
				notice.destroy();
				CKEDITOR.remove(notice);
			}
			$("#showScmNotice").hide();
		});		
		if ( $('#isScmN:checked').val() == 'N' || $('#isScmB:checked').val() == 'B'){
			var notice = CKEDITOR.instances['scmNotice'];
			if(notice){
				notice.destroy();
				CKEDITOR.remove(notice);
			}
			$("#showScmNotice").hide();
		}else{
			$("#showScmNotice").show();
			dispScmNotice();
		}
		</c-rt:if>
		//BO及SCM商品才可开立预购和订制卖场
	 	<c-rt:choose>
			<c-rt:when test="${(product.productType eq '0' or product.productType eq '1') and not empty product.isScm and product.isScm ne 'N' }">
				$("#showUseDeliveryDay").show();
			</c-rt:when>
			<c-rt:otherwise>
				$("#showUseDeliveryDay").hide();
			</c-rt:otherwise>
		</c-rt:choose>
		$('input[name=useDeliveryDay]').each(function(){
			 $(this).click(function(){
				 if ( $(this).val() == "Y" ){
			 	 		$("#showDeliveryDayTh").show();
			 	 		$("#showDeliveryDayTd").show();
			 	 }else{
			 		$("#showDeliveryDayTh").hide();
		 	 		$("#showDeliveryDayTd").hide();
			 	 }
				 $("#deliveryDay").val("0");
			 });
		 });
		$("#getSupplier").click(function() {
			$("#spId").val("");
			$("#spName").val("");
			doAR('${supplierPops}', 'dialog'); 
			openDialog('供应商搜寻',content, 550, 440);
		});	 
		$("#getTwSupplier").click(function() {
			$("#spId").val("twSupplierIdParam");
			$("#spName").val("twSupplierCompanyName");
			doAR('${supplierPops}', 'dialog'); 
			openDialog('供应商搜寻',content, 550, 440);
		});	 
		$("#getBrand").click(function() {
			doAR('${brandPops}', 'dialog'); 
			openDialog('品牌搜寻',content, 550, 440);
		});	
	 $("#loadingImg").dialog({
		  title: '资料载入中',
			bgiframe: true,
			autoOpen: false,
			height: 150,
			width:280,
			modal: true
		});
	 $('#expectShipDate').datepick({minDate: '+1D', maxDate: '+45D',showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '<%=ServerValue.getMidContextPath()%>/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-1:+1'});

	 $("input[name=isScm]").each(function(){
		 $(this).click(function(){
			 initType($(this).val());
		 });
	 });
	<c-rt:if test="${not empty product.productId}">
		initType("${product.isScm}");
 		initDeliveryDay("${product.isScm}","${product.productType}");
 		<c-rt:if test="${not empty product.productType}">
 			$("input[name=type][type=radio]").eq("${product.productType}").attr("checked", true);
 			if ( "1" == "${product.productType}" ){
				$("#showExpectShipDate").show();
			}
		</c-rt:if>
		<c-rt:if test="${product.useDeliveryDay eq 'Y'}">
			$("input[name=useDeliveryDay][type=radio]").eq(0).attr("checked", true);
			$("#showDeliveryDayTh").show();
			$("#showDeliveryDayTd").show();
			$("#deliveryDay").val("${product.deliveryDay}");
		</c-rt:if>
 	</c-rt:if>
 	<c-rt:if test="${empty product.productId}">
 		initType("B");
 	</c-rt:if>
 	<c-rt:if test="${empty product.productId and copy eq 'Y'}">
 		initType("${isScm}");
		initDeliveryDay("${isScm}","${type}");
		<c-rt:if test="${not empty type}">
			if ( "N" == "${isScm}" ){
				if ( "0" == "${type}" ){
					$("input[name=type][type=radio]").eq(0).attr("checked", true);	
	 			}
				if ( "2" == "${type}" ){
					$("input[name=type][type=radio]").eq(1).attr("checked", true);	
	 			}
				if ( "3" == "${type}" ){
					$("input[name=type][type=radio]").eq(2).attr("checked", true);	
	 			}
			}else{//Y or B
				$("input[name=type][type=radio]").eq("${type}").attr("checked", true);
			} 
			if ( "1" == "${type}" ){
				$("#showExpectShipDate").show();
			}
		</c-rt:if>	
 	</c-rt:if>
 	
	 $("input[name=type]").each(function(){
		 $(this).click(function(){
			 	//initDeliveryDay($('input[name=isScm]:radio:checked').val(),$(this).val());
			 	<c-rt:choose>
				<c-rt:when test="${not empty product.productId and product.isScm ne 'B'}">
				initDeliveryDay("${product.isScm}",$(this).val());
				</c-rt:when>
				<c-rt:otherwise>
					initDeliveryDay($('input[name=isScm]:radio:checked').val(),$(this).val());
				</c-rt:otherwise>
			</c-rt:choose>
			 	
		 });
	 });
	 
	 if ( $('input[name=type]:checked').val() == 1) $("#showExpectShipDate").show();
	 //$.formValidator.initConfig({formid:"productForm",onerror:function(msg){alert(msg)},onsuccess:function(){return true;}});
	 $("#supplierIdParam").numeric();
	 $("#length").numeric();
	 $("#width").numeric();
	 $("#height").numeric();
	 $("#weight").numeric();
	 $("#tax").numeric({allow:"."});
	 $("#minpo").numeric();
	 $("#maxpo").numeric();
	 $("#editleadtime").numeric();
	 $("#showSeq").numeric();
	 $("#cost").numeric({allow:"."});
	 $("#price").numeric({allow:"."});
	 $("#prpsShelfPrice").numeric({allow:"."});
	 $("#deliveryDay").numeric();
	 $("#length").blur(function(){
		 calcVolume();
	 });
	 
	 $("#width").blur(function(){
		 calcVolume();
	 });

	 $("#height").blur(function(){
		 calcVolume();
	 });
	//load default value
	if ( "" != $("#tempCategoryPath").val()){ 
		calcVolume();
		var tempId = $("#tempCategoryPath").val().split("/");
		if ( $("#orderNotice").val() == "" )
			$.post("${midContextPath}/product/loadOrderNotice.do",{categoryId:tempId[0]},orderNoticeCallback,"json");
		$("#categorySelect").val(tempId[0]).attr("selected","selected");
		$("#mainCategoryId").val(tempId[tempId.length -1]);
		$.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[0]},elementSelectCallback,"json");
	}
	//第0层
	$("#categorySelect").click(function(){
		if ( null != $(this).val()  ){
			<c-rt:if test="${empty product.productId and copy eq 'N'}">
		    if ( $(this).val() == "1726" || $(this).val() == "1727" || $(this).val() == "1728" ){
		    	$('input[name=graphicType]').get(1).checked = true;
		    	$('input[name=graphicType]').get(0).checked = false;
		    }else{
		    	$('input[name=graphicType]').get(1).checked = false;
		    	$('input[name=graphicType]').get(0).checked = true;
		    }
		  </c-rt:if>
			$.post("${midContextPath}/product/loadOrderNotice.do",{categoryId:$(this).val()},orderNoticeCallback,"json");
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'elementSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
						$('#elementSelect').find('option').remove().end();
				 		$('#attributeSelect').find('option').remove().end();
				 		$('#itemSelect').find('option').remove().end();
				 		$('#unitSelect').find('option').remove().end();
				 		$('#listSelect').find('option').remove().end();					
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	elementSelectCallback(strData);
				}
			});
		}
		$("#mainCategoryId").val($(this).val());
		$("#tempCategoryPath").val("");
	});
	//第1层
	$("#elementSelect").click(function(){
		if ( null != $(this).val()  ){
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'attributeSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
						$('#attributeSelect').find('option').remove().end();
					  $('#itemSelect').find('option').remove().end();
					  $('#unitSelect').find('option').remove().end();
					  $('#listSelect').find('option').remove().end();						
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	attributeSelectCallback(strData);
				}
			});	  
			//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},attributeSelectCallback,"json");
			$("#mainCategoryId").val($(this).val());
			$("#tempCategoryPath").val("");
		}
	});
	//第2层
	$("#attributeSelect").click(function(){
		if ( null != $(this).val()  ){
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'itemSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
					  $('#itemSelect').find('option').remove().end();
					  $('#unitSelect').find('option').remove().end();
					  $('#listSelect').find('option').remove().end();
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	itemSelectCallback(strData);
				}
			});	  	
			//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},itemSelectCallback,"json");
			$("#mainCategoryId").val($(this).val());
			$("#tempCategoryPath").val("");
		}
	});
	//第三层
	$("#itemSelect").click(function(){
		if ( null != $(this).val()  ){
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'unitSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
					  $('#unitSelect').find('option').remove().end();
					  $('#listSelect').find('option').remove().end();
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	unitSelectCallback(strData);
				}
			});	 	  	
			//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},unitSelectCallback,"json");
			$("#mainCategoryId").val($(this).val());
			$("#tempCategoryPath").val("");
		}
	});
	//第四层
	$("#unitSelect").click(function(){
		if ( null != $(this).val()  ){
			$.ajax({
			    url: '${midContextPath}/category/getProductCategory.do',
			    type: 'post',
			    dataType: 'json',
			    data: {categoryid:$(this).val(), callback: 'listSelectCallback'},
			    cache: false,
			    beforeSend: function(xhr) {
						$("#loadingImg").dialog("open");
						$('#listSelect').find('option').remove().end();
			    },
			    success: function( strData ){
			    	$("#loadingImg").dialog("close");
			    	listSelectCallback(strData);
				}
			});	  	
			//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},unitSelectCallback,"json");
			$("#mainCategoryId").val($(this).val());
			$("#tempCategoryPath").val("");
		}
	});		
	//第五层
	$("#listSelect").click(function(){
		if ( null != $(this).val()  ){
			$("#mainCategoryId").val($(this).val());
			$("#tempCategoryPath").val("");
			combineCategoryPath();
			checkIsEndNodex();
		}
	});				  
	    
	$("input[name*='submit']").click(function(){
		validate_data();
	});
 });

 	function disabledBtn(){
 		$("input[type='button']").each(function(){
			$(this).attr("disabled","disabled");
		});
   	if($("#productAttribute").val()=='Y' ||$("#productAttribute").val()=='H' || $("#productAttribute").val()=='Q'){
		  var sProdStatus="";
		  if($("#productAttribute").val()=='Y'){
		   sProdStatus="Y-不可查询,不可销售";
		  }
		  if($("#productAttribute").val()=='H'){
		   sProdStatus="H-不可查询,可销售";
		  }
		  if($("#productAttribute").val()=='Q'){
		   sProdStatus="Q-可查询,不可销售";
		  }
			if(window.confirm('本商品之销售状态设为'+sProdStatus+'，是否确认？')){
				$("#productForm").submit();
			}else{
				$("input[type='button']").each(function(){
					$(this).attr("disabled","");
				});
				return false;
			}
		}else{
			$("#productForm").submit();
		}
 	}
	 function validate_data(){
		 	var brief_result = true;
		 	if ($("#name").val() == "" ){
				alert("请输入商品名称");
				$("#name").focus();
				return false;
			}
			<c-rt:if test="${empty product.productId}">
			if ( $('input[name=isScm]').is(":checked") == false ){
				alert("请选择采购类型");
				return false;
			}
			</c-rt:if>
			if ($('input[name=type]').is(":checked") == false){
				alert("请输入商品型态(一般商品,预购,赠品,配件) ");
				return false;
			}
			if ( $('input[name=isScm]:checked').val() == 'Y' || $('input[name=isScm]:checked').val() == 'B' ){
				if ( $('input[name=useDeliveryDay]:checked').val() == 'Y'){
					if ( $("#deliveryDay").val() == "" || parseInt($("#deliveryDay").val(),10) == 0 ){
						alert("订制商品天数不可为空值且必须大于0天");
						$("#useDeliveryDay").focus();
						return false;
					}
				}
			}			
			if ($('#mainCategoryId').val()==""){
				alert("请输入主目录");
				return false;
			}				
			if ( $("#mainCategory").text() == "" || $("#isEndNode").val() != "Y" ){
				alert("请选择最底层的目录");
				return false;
			}			 
			if ( $('input[name=type]:checked').val() == 1 ){
				if ( $("#expectShipDate").val() == "" ){
					alert("请选择预计出货日");
					$("#expectShipDate").focus();
					return false;
				}
			}
			if ( $("#productAttribute").val()  =="" ){
				alert("请选择销售状态");
				$("#productAttribute").focus();
				return false;
			}
			
			if ( $("#showSeq").val() == "" ){
					alert("请输入排序【000～999】");
					$("#showSeq").focus();
					return false;
			}
			<c-rt:if test="${empty product.productId}">
			try{
				if($("#cost").val()==''){
					$("#cost").val()=0.00;
				}
				if ($('input[name=type]:checked').val() != '2' ) {
					if (parseFloat($("#cost").val()) <= 0.00 ){
						alert("非赠品成本必须大于 0.00");
						$("#cost").focus();
						return false;
					}
				} else {
					if (parseFloat($("#cost").val()) < 0.00 ){
						alert("成本小于 0.00");
						$("#cost").focus();
						return false;
					}
				}
			} catch (err) {
				alert("请输入成本 ");
				$("#cost").focus();
				return false;
			}
			</c-rt:if>
			if ($("#price").val() == "" ){
				alert("请输入厂商建议售价(市价)");
				$("#price").focus();
				return false;
			}
			if ($("#length").val() == "" ){
				alert("请输入长");
				$("#length").focus();
				return false;
			}
			if ($("#width").val() == "" ){
				alert("请输入宽");
				$("#width").focus();
				return false;
			}
			if ($("#height").val() == "" ){
				alert("请输入高");
				$("#height").focus();
				return false;
			}
			if ($("#weight").val() == "" ){
				alert("请输入重量");
				$("#weight").focus();
				return false;
			}
			if ($("#unit").val() == "" ){
				alert("请输入單位");
				$("#unit").focus();
				return false;
			}
			if ($("#editDeliverGeoRange").val() == "" ){
				alert("运送限定区域");
				$("#editDeliverGeoRange").focus();
				return false;
			}
			if ( $("#supplierIdParam").val() == ""){
				alert("请选择供应商");
				$("#supplierIdParam").focus();
				return false;
			}
			if ( $("#supplierIdParam").val() == "010000" || $("#supplierIdParam").val() == "010001"){
				<c-rt:if test="${empty product.productId}">
					if ( $('input[name=isScm]:checked').val() == 'Y' ){
						alert("若供应商为万美供应商，采购模式不可为转单");
						return false;
					}
				</c-rt:if>
				<c-rt:if test="${not empty product.productId}">
					if ( "${product.isScm}" == "Y" ){
						alert("若供应商为万美供应商，采购模式不可为转单");
						return false;
					}
				</c-rt:if>
				if (  $("#twSupplierIdParam").val() == "" ) {
					alert("若供应商为万美供应商，台湾供应商为必填");
					$("#twSupplierIdParam").focus();
					return false;
				}
			}

			//if ( $("#brandIdParam").val() == ""){
				//alert("请选择品牌");
				//$("#brandIdParam").focus();
				//return false;
			//}
			if ( $("#pm").val() == ""){
				alert("请选择主要负责PM");
				$("#pm").focus();
				return false;
			}
			if ($("#organization").val() == ""){
				alert("请选择PM所属部门");
				$("#organization").focus();
				return false;
			}
			if( $("#brief").val() == ""){
				alert("请输入商品特色");
				return false;
			}else{
			 var xxx = $("#brief").val().length;
			 var k = 0;
			 for(var i = 0 ; i < xxx; i++ ){
				 if ( $("#brief").val().charAt(i) == "\n"){
					 k++;
				 }
			 }
			 if ( k > 4 ){
				 alert("商品特色最多只能输入五行");
				 return false;
			 }
			 if ( k == 0 ){
				 if ( $("#brief").val().length > 30 ){
					 alert("商品特色第1行字数长度 超过30");
					 brief_result = false;
				 }
			 }else{
				 if ( $("#brief").val().indexOf("\n") != -1 ){
					 var briefArray = $("#brief").val().split("\n");
					 var ii = 0;
					 while( brief_result && ii <=briefArray.length-1 && ii < 5) {
						 if ( briefArray[ii].length > 30 ){
							 alert("商品特色第" + (ii+1) + "行字数长度 超过30");
							 brief_result = false;
						 }
						 ii++;
					 }
				 }
			 }
			}			
			if ( brief_result == false) return false;

			var description = CKEDITOR.instances.description.getData();
			description = description.replace("<br />","");
			description = description.replace("<br>","");
			description = trim(description);
			if(description==""){
				alert("请输入商品描述");
				return false;
			}
			$("#description").val(description);
			var details = CKEDITOR.instances.details.getData();
			details = details.replace("<br />","");
			details = details.replace("<br>","");
			details = trim(details);
			if(details==""){
				alert("请输入規則參數");
				return false;
			}			
			$("#details").val(details);
			if(CKEDITOR.instances['scmNotice']){
				var scmNotice = CKEDITOR.instances.scmNotice.getData();
				scmNotice = scmNotice.replace("<br />","");
				scmNotice = scmNotice.replace("<br>","");
				scmNotice = trim(scmNotice);
				$("#scmNotice").val(scmNotice);
			}else{
				$("#scmNotice").val("");
			}
			/*
			if ($("#prpsShelfPrice").val() == "" ){
				alert("请输入提报耀点价");
				$("#prpsShelfPrice").focus();
				return false;
			}	
			if ( parseFloat($("#prpsShelfPrice").val()) == 0.00){
				alert("提报耀点价不可等于0");
				$("#prpsShelfPrice").focus();
				return false;
			}
			*/
			//if ( $('#isScmY:checked').val() == 'Y'){
				$.ajax({
				    url: '${midContextPath}/product/findSupplierApply.do',
				    type: 'post',
				    dataType: 'json',
				    data: {editsupplier:$("#supplierIdParam").val()},
				    cache: false,
				    success: function(spResult){
				    	supplierCallback(spResult);
						}
				});
			//}else{
			//	disabledBtn();
			//}	
	 }

	
	
	 function supplierCallback(spResult){
		 var rsVal = spResult.split(",");
		// 转单商品&非转单供应商=>alert 說明 & update 商品
		 if ( $('#isScmY:checked').val() == 'Y' || "${product.isScm}" == 'Y'){//轉單商品
			 if ( rsVal[0] == "false" ){
				alert("供应商发货资料不正确");
				return false;
			 }
			 if ( rsVal[1] == "N" && ($('#isScmY:checked').val() == 'Y' || "${product.isScm}" == 'Y') ){
				 alert("供应商为非转单供应商,采购模式只可为入仓或BO");
				 return false;
			 }
			 if ( rsVal[0] == "true" && rsVal[1] == "Y" ){
				 disabledBtn();
			 } 
		 }else{// 轉單供應商&非轉單商品 要異動商品的轉單資料=>不理会
			 disabledBtn();
		 }
	 } 
	 
		//去掉空格
	 function trim(str){
	    return str.replace(/(^\s*)|(\s*$)/g,"");
	 }

	function initType(obj){
		defultType();
		if ( obj == "N" ) {//PO
			if ($('input[name=type]:radio:checked').val() != 1 ) {
				$("#type1").hide();//預購
				<yaodian100:checkPermission permissions="ROLE_PMPO">
				$("#type1").show();//預購
				</yaodian100:checkPermission>
		  }
		}
	}

	function initDeliveryDay(isScm,type){
		defaultDeliveryDay();
		if ( isScm == "B" || isScm == "Y" ){//BO&SCM
			if ( type == "0" || type == "1"){//一般&預購
				$("#showUseDeliveryDay").show();
			  $("input[name=useDeliveryDay][type=radio]").attr("checked",'N');
			}
		}
		if ( isScm == "N" ) {//PO
			if (type != 1 ) {
				$("#type1").hide();//預購
				<yaodian100:checkPermission permissions="ROLE_PMPO">
				$("#type1").show();//預購
				</yaodian100:checkPermission>
		  }
		}
		if ( type == "1" ){
			$("#showExpectShipDate").show();
		} else {
			$("#showExpectShipDate").hide();
		}
		
	}

	function defultType(){
		$("#type0").show();//一般
		$("#type1").show();//預購
		$("#type2").show();//贈品
		$("#type3").show();//配件
		$("#type7").show();//限定立即购买商品
	}

	//訂制天數預設值
	function defaultDeliveryDay(){
		$("#showUseDeliveryDay").hide();
	  $("input[name=useDeliveryDay][type=radio]").attr("checked",'');
	  $("#deliveryDay").val("0");
		$("#showDeliveryDayTh").hide();
 	 	$("#showDeliveryDayTd").hide();
	}
	 
	//计算体积
	function calcVolume(){
		$("#volume").val($("#length").val()* $("#width").val()*$("#height").val());
	}	
 	//购物须知ajax
	function orderNoticeCallback(jsonOrderNotice){
		CKEDITOR.instances.orderNotice.setData(jsonOrderNotice);
	}	
	//判断是否为最底层
 	function checkIsEndNodex(){
  	$.post("${midContextPath}/product/getJsonCategoryData.do",{mainCategoryId : $("#mainCategoryId").val()},endNodeCallback,"json");
 	}	
 	function endNodeCallback(categoryResult){
 			$("#isEndNode").val(categoryResult);
 	}
	function categoryCallback(fullCategoryPath){
		 $("#mainCategory").html(fullCategoryPath);
	} 
	function elementSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}         		 
				if ( categories[i].id == tempId[1] ){
					$('#elementSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#elementSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 1 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[1]},attributeSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}
         		 if(categories[i].isVisible=="N"){
         			 cmark=cmark+'※';//是否可見
        		} 
					$("#isEndNode").val(categories[i].isEndnode);
					$('#elementSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
		
	}
	function attributeSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
				if ( categories[i].id == tempId[2] ){
					$('#attributeSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#attributeSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 2 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[2]},itemSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
					$("#isEndNode").val(categories[i].isEndnode);
					$('#attributeSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}
	function itemSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
				if ( categories[i].id == tempId[3] ) {
					$('#itemSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#itemSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 3 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[3]},unitSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
					$("#isEndNode").val(categories[i].isEndnode);
					$('#itemSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}
	function unitSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
				if ( categories[i].id == tempId[4] ) {
					$('#unitSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#unitSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 4 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[4]},listSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
					$("#isEndNode").val(categories[i].isEndnode);
					$('#unitSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}
	function listSelectCallback(categories){
		if ( "" != $("#tempCategoryPath").val()){
			var tempId = $("#tempCategoryPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
				if ( categories[i].id == tempId[5] ) {
					$('#listSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#listSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		}    
					$("#isEndNode").val(categories[i].isEndnode);
					$('#listSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}			
	//组合目录路径
	function combineCategoryPath(){
		var categoryTemp = $('#categorySelect option:selected').text(); 
		var elementTemp =  $('#elementSelect option:selected').text();
		var attributeTemp = $('#attributeSelect option:selected').text();
		var itemTemp = $('#itemSelect option:selected').text();
		var unitTemp = $('#unitSelect option:selected').text();
		var listTemp = $('#listSelect option:selected').text();
		var textTemp ;
		if ( "" != categoryTemp ) textTemp = categoryTemp;
		if ( "" != elementTemp ) textTemp = textTemp + " > " +  elementTemp;
		if ( "" != attributeTemp ) textTemp = textTemp + " > " +  attributeTemp;
		if ( "" != itemTemp ) textTemp = textTemp + " > " +  itemTemp;
		if ( "" != unitTemp ) textTemp = textTemp + " > " +  unitTemp;
		if ( "" != unitTemp ) textTemp = textTemp + " > " +  listTemp;
		$("#mainCategory").html(textTemp);
	} 		   
</script>
<style type="text/css">
.msg{float:left; line-height:1em; margin:0; display:block;border:1px solid #f66;padding:2px 5px;*padding:2px 5px 1px;}
.msg.rn{background-color:#fff2f2;border-color:#f66;}
</style>
<s:if test="hasActionErrors()">
	<s:actionerror cssClass="msg rn"/>
</s:if>
<s:if test="hasActionMessages()">
	<s:actionmessage cssClass="msg rn"/>
</s:if>
<p></p>
<h1>商品管理 - 商品主檔${chkInventory}<br/>
<div class="f-link">
	<a href="${midContextPath}/product/copy.do?productId=${product.productId}">复制</a>
	<a href="${midContextPath}/product/list.do">回商品列表页</a>
</div>
</h1>
<br/>
<c-rt:if test="${not empty product.productId}">
	<jsp:include page="commonMenu.jsp"/>
</c-rt:if>
<s:form action="save.do" method="post" id="productForm">
<table class="tb-data" width="100%">
		<tr>
			<th>商品编号</th>			
			<td colspan="3"> 
				<c-rt:choose>
					<c-rt:when test="${empty product.productId}">
					系统流水号发放
					</c-rt:when>
					<c-rt:otherwise>
						${product.productId}
						<yaodian100:productImg productId="${product.productId}" postfix="m75" />
					</c-rt:otherwise>
				</c-rt:choose>
			</td>
		</tr>
		<tr>
			<th>*商品名称</th>			
			<td colspan="3">        
			   <input type="text" name="name" id="name" size="100" value="${product.productName}"/>
      </td>
	  </tr>
	  <tr>	
			<th>*采购模式</th>			
			<td>
				<c-rt:choose>
					<c-rt:when test="${not empty product.productId and product.isScm ne 'B'}">
						<c-rt:if test="${empty product.isScm or product.isScm eq 'N'}">入仓</c-rt:if>
						<c-rt:if test="${product.isScm eq 'B'}">BO</c-rt:if>
						<c-rt:if test="${product.isScm eq 'Y'}">SCM</c-rt:if>
						<input type="hidden" id="isScm" name="isScm" value="${product.isScm}"/>
					</c-rt:when>
					<c-rt:when test="${not empty product.productId and product.isScm eq 'B'}">
						<input id="isScmN" name="isScm" type="radio" value="N" <c-rt:if test="${empty product.isScm or product.isScm eq 'N'}">checked="checked"</c-rt:if>/>入仓
		    		<input id="isScmB" name="isScm" type="radio" value="B" <c-rt:if test="${product.isScm eq 'B'}">checked="checked"</c-rt:if>/>BO					
					</c-rt:when>
					<c-rt:otherwise>
						<input id="isScmN" name="isScm" type="radio" value="N" <c-rt:if test="${product.isScm eq 'N'}">checked="checked"</c-rt:if>/>入仓
						<input id="isScmB" name="isScm" type="radio" value="B" <c-rt:if test="${empty product.isScm or product.isScm eq 'B'}">checked="checked"</c-rt:if>/>BO
        		<input id="isScmY" name="isScm" type="radio" value="Y" <c-rt:if test="${product.isScm eq 'Y'}">checked="checked"</c-rt:if>/>SCM
					</c-rt:otherwise>
				</c-rt:choose>
				<a href="${midContextPath}/images/scm.png" target="_blank">采购模式说明</a>
			</td>
		</tr>		 		  
		<tr>
			<th >*商品型态 </th>			
			<td>
				<c:if test="${product.productType eq '7'}">
					<span id="type7"><input name="type" type="radio" value="7" <c:if test="${product.productType eq '7'}">checked="checked"</c:if>/>限定立即购买商品</span>
				</c:if>
				<c:if test="${product.productType ne '7'}">
	        <span id="type0"><input name="type" type="radio" value="0" <c:if test="${empty product.productType or product.productType eq '0'}">checked="checked"</c:if>/>一般商品</span>
	        <span id="type1"><input name="type" type="radio" value="1" <c:if test="${product.productType eq '1'}">checked="checked"</c:if>/>预购</span>
	        <span id="type2"><input name="type" type="radio" value="2" <c:if test="${product.productType eq '2'}">checked="checked"</c:if>/>赠品</span>
	        <span id="type3"><input name="type" type="radio" value="3" <c:if test="${product.productType eq '3'}">checked="checked"</c:if>/>配件(加购)</span>
	        <span id="type7"><input name="type" type="radio" value="7"/>限定立即购买商品</span>
        </c:if>
      </td>
	  	<th>*销售状态</th>
	  	<td>
	  		<s:select id="productAttribute" name="productAttribute" list="attributeMenu.options" listKey="key"  listValue="value.name" headerKey="" headerValue="---请选择销售状态---"/>
	  	</td>
	  </tr>
	 	<tr id="showUseDeliveryDay" style="display:none;">
		 	<th>是否使用<br/>"订制商品"?</th>
	 		<td>
				<input name="useDeliveryDay" type="radio" value="Y" <c:if test="${product.useDeliveryDay eq 'Y'}">checked="checked"</c:if>/>是
		    <input name="useDeliveryDay" type="radio" value="N" <c:if test="${product.useDeliveryDay eq 'N'}">checked="checked"</c:if>/>否
		    <br/><span class="txt-rd">【※请确认出货所需天数（供应商进货+物流理货保守估计约3天），<br/>一旦填入该出货时间会在前台显示】</span>
			</td>
	 		<th id="showDeliveryDayTh" style="display:none;">订制商品天数</th>
	 		<td id="showDeliveryDayTd" style="display:none;">
				<input id="deliveryDay" name="deliveryDay" type="text" value="${product.deliveryDay}"/>
		  </td>
	 	</tr>		 
	 <c-rt:if test="${copy eq 'N'}">
		  <tr>
				<th >	建立者<br/>
					建立日期<br/>
					</th><td >
					 	${product.createUser}<br/>
						<fmt:formatDate value="${product.createDate}" pattern="yyyy-MM-dd HH:mm:ss" /><br/>
						</td><th >
					修改者<br/>
					修改日期</th>	<td > 	
						${product.modifyUser}<br/>
						<fmt:formatDate value="${product.modifyDate}" pattern="yyyy-MM-dd HH:mm:ss" />
					</td>
		  	<td>
		  	</td>
		  </tr>
	  </c-rt:if>	 	 
		<tr>
			<th>*主分类</th>			
			<td colspan="3">
				<span class="txt-rd">○符号表示该分类为品牌;◎表活動</span><br/>
				<select id="categorySelect" name="categoryid" size="5" class="selCont">
         	<c-rt:forEach items="${rootCategories}" var="category">
						<option value="${category.id}">${category.name}(${category.id})</option>
					</c-rt:forEach>
        </select>       
        <select id="elementSelect" name="categoryid" size="5" class="selCont">            	
        </select>
        <select id="attributeSelect" name="categoryid" size="5" class="selCont">
        </select>
        <br/>
        <select id="itemSelect" name="categoryid" size="5" class="selCont">
        </select>
        <select id="unitSelect" name="categoryid" size="5" class="selCont">
        </select>
        <select id="listSelect" name="categoryid" size="5" class="selCont">
        </select>
        <br/>
                          主分类为：<span id="mainCategory"></span><br/>
			</td>
		</tr>
		<tr id="showExpectShipDate" style="display:none;">
			<th>*预计出货日</th>
			<td colspan="3">
				<fmt-rt:formatDate value="${product.expectShipDate}" pattern="yyyy-MM-dd" var="fmtDate"/>
				<input type="text" name="expectShipDate" id="expectShipDate" value="${fmtDate}"/><br/>
				预购商品日期的最大值T+45天
			</td>
		</tr>
		<tr>
			<input type="hidden" name="showSeq" maxlength="3" id="showSeq" size="3" value="${product.showSeq}" />
			<th>${not empty product.productId ? '': '*'}商品成本</th>			
			<td>
			<c-rt:choose>
				<c-rt:when test="${not empty product.productId}">
					<fmt-rt:formatNumber value="${product.productCost}" pattern="#####0.00"/>
				</c-rt:when>
				<c-rt:otherwise>
					<fmt-rt:formatNumber value="${product.productCost}" pattern="#####0.00" var="productCost"/>
					<input id="cost" name="cost" type="text" value="${productCost}"/>	
				</c-rt:otherwise>
			</c-rt:choose>
			<br/><span class="txt-rd">【※商品成本小数点2位数后无条件舍去】</span>
			<br/><span class="txt-rd">新增后无法修改,由后台计实后同步</span>
			</td>
			<th>*效期管理分类</th>
			<td>
				<s:select id="expireManage" name="expireManage" list="expireManageMenu.options" listKey="key"  listValue="value.name"/>
			</td>						
		</tr>
		<tr>
			<th>*厂商建议售价(市价)</th>			
			<fmt-rt:formatNumber value="${product.listPrice}" pattern="#####0.0" var="listPrice"/>
			<td><input id="price" name="price" type="text" value="${listPrice}"/><br/><span class="txt-rd">【※厂商建议售价小数点1位数后无条件舍去】</span></td>
			<th>税率类别(%)</th>			
			<td><input id="tax" name="tax" type="text" value="${product.taxClass}"/>
			<br/>%【例:17%,请直接输入17】
			</td>
		</tr>
		<tr>
			<th>前置时间(天)</th>			
			<td><input id="editleadtime" name="editleadtime" type="text" value="${product.leadTime}"/></td>
			<th>是否允许超收</th>			
			<td>
				<input name="delivertolerance" type="radio" value="Y" <c:if test="${empty product.isDeliverTolerance or product.isDeliverTolerance eq 'Y'}">checked="checked"</c:if>/>是
        <input name="delivertolerance" type="radio" value="N" <c:if test="${product.isDeliverTolerance eq 'N' }">checked="checked"</c:if>/>否
      </td>
	  </tr>
		<tr>
			<th>商品体积</th>			
     	<td colspan="3">
				*长(cm)：<input type="text" name="length" id="length" value="${product.productLength}"/>,
				*宽(cm):<input type="text" name="width" id="width" value="${product.productWidth}"/>,
				*高(cm)：<input type="text" name="height" id="height" value="${product.productHeight}"/><br/>
				【注:长宽高请输入整数】<br/>
				*体积(cm3):	<input type="text" name="volume" id="volume" value="${product.productVolume}" readonly="readonly"/>,
       	*重量（g):<input type="text" name="weight" id="weight" value="${product.productWeight}"/>,
				*销售单位(例如件, 个, 罐,...):<input type="text" name="unit" id="unit" value="${product.productUnit}"/>
			</td>
	  </tr>
		<tr>
			<th>最小采购量</th>			
     	<td>
				<input type="text" name="minpo" id="minpo" value="${product.minPOQuantity eq 0 ? 1 : product.minPOQuantity}"/>
			</td>
			<th>最大采购量</th>
			<td>
				<input type="text" name="maxpo" id="maxpo" value="${product.maxPOQuantity eq 0 ? 1 : product.maxPOQuantity}"/>
      </td>
	  </tr>
		<tr>
			<th>物流运送温层类别</th>			
			<td>
	     	<input name="temperature" type="radio" value="1" <c:if test="${product.temperatureType eq '0' or product.temperatureType eq '1'}">checked="checked"</c:if>/>常溫
        <input name="temperature" type="radio" value="2" <c:if test="${product.temperatureType eq '2'}">checked="checked"</c:if>/>冷藏
        <input name="temperature" type="radio" value="3" <c:if test="${product.temperatureType eq '3'}">checked="checked"</c:if>/>冷冻
      </td>
			<th>退换货时是否需取回</th>			
			<td>
	      <input name="returnpickup" type="radio" value="Y" <c:if test="${empty product.isReturnPickup or product.isReturnPickup eq 'Y'}">checked="checked"</c:if>/>是
        <input name="returnpickup" type="radio" value="N" <c:if test="${product.isReturnPickup eq 'N'}">checked="checked"</c:if>/>否
      </td>
	  </tr>
	  <tr>
			<th>*运送限定区域</th>			
			<td>
				<s:select id="editDeliverGeoRange" name="editDeliverGeoRange" list="freightMenu.options" listKey="key"  listValue="value.name" headerKey="" headerValue="--请选择--"/>
      </td>
			<th>此商品可否退换货</th>			
			<td>
				<input name="returnable" type="radio" value="Y" <c:if test="${empty product.isReturnable or product.isReturnable eq 'Y'}">checked="checked"</c:if>/>是
        <input name="returnable" type="radio" value="N" <c:if test="${product.isReturnable eq 'N'}">checked="checked"</c:if>/>否
      </td>
	  </tr>
	  <c:choose>
		<c:when test="${not empty product.productId}">
			<tr>
				<th>商品状态</th>			
				<td>已审核</td>
				<th>购买时是否需验证码</th>			
				<td>
					<input name="isValidateNum" type="radio" value="Y" <c:if test="${empty product.isValidateNum or product.isValidateNum eq 'Y'}">checked="checked"</c:if>/>是
  	      <input name="isValidateNum" type="radio" value="N" <c:if test="${product.isValidateNum eq 'N'}">checked="checked"</c:if>/>否
				</td>
		  </tr>
 		</c:when>
 		<c:otherwise>
 			<tr>
				<th>购买时是否需验证码</th>			
				<td colspan="3">
					<input name="isValidateNum" type="radio" value="Y" <c:if test="${empty product.isValidateNum or product.isValidateNum eq 'Y'}">checked="checked"</c:if>/>是
  	      <input name="isValidateNum" type="radio" value="N" <c:if test="${product.isValidateNum eq 'N'}">checked="checked"</c:if>/>否
				</td>
		  </tr>
 		</c:otherwise>
 		</c:choose>
		<tr>
			<th>* 供应商</th>
			<td>
				<c-rt:choose>
					<c-rt:when test="${not empty product.productId and editsupplier eq '010000' or editsupplier eq '010001'}">
						${editsupplier} ${supplierCompanyName}
						<s:hidden name="editsupplier" id="supplierIdParam"/>
					</c-rt:when>
					<c-rt:otherwise>
						<s:textfield name="editsupplier" id="supplierIdParam"  maxlength="6"/>
						<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" 
							id="getSupplier"/>
						<input type="text" id="supplierCompanyName" value="${supplierCompanyName}" readonly="readonly" size="60" style="border: 0px;"/>
					</c-rt:otherwise>
				</c-rt:choose>
				<c-rt:if test="${not empty product.productId and canUpdSupplier ne 'N' }"><br/>
					<a href="javascript:void(0);" onclick="chk24hr();">新增异动供应商</a>
				</c-rt:if>
			</td>
			<th>是否需要防拆包材</th>
			<td>
				<input name="isAntiUnpacking" type="radio" value="Y" <c:if test="${empty product.isAntiUnpacking or product.isAntiUnpacking eq 'Y'}">checked="checked"</c:if>/>是
        <input name="isAntiUnpacking" type="radio" value="N" <c:if test="${product.isAntiUnpacking eq 'N'}">checked="checked"</c:if>/>否			
			</td>			
		</tr>
		<tr id="twSupplier" style="display:none;">
			<th>* 台湾馆供应商</th>
			<td colspan="3">
				<c-rt:choose>
					<c-rt:when test="${not empty product.productId and editsupplier eq '010000' or editsupplier eq '010001'}">
						${editTwSupplier} ${twSupplierCompanyName}
						<s:hidden name="editTwSupplier" id="twSupplierIdParam"/>
					</c-rt:when>
					<c-rt:otherwise>
						<s:textfield name="editTwSupplier" id="twSupplierIdParam"  maxlength="6" readonly="readonly"/>
						<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" 
								id="getTwSupplier"/>
						<input type="text" id="twSupplierCompanyName" value="${twSupplierCompanyName}" readonly="readonly" size="60" style="border: 0px;"/>
					</c-rt:otherwise>
				</c-rt:choose>
			</td>
		</tr>		
	  <tr>
	  	<th>主要负责PM</th>			
			<td>
				<s:select id="pm" name="pm" list="users" listKey="username"  listValue="nameNative" headerKey="" headerValue="--请选择--"/>
			</td>
			<th>PM所属单位</th>
			<td><s:select id="organization" name="organization" list="groups" listKey="code"  listValue="description" headerKey="" headerValue="--请选择--"/></td>
	  </tr>
	   <tr>
			<th>品牌</th>			
     		<td>
		     	<s:textfield name="editbrand" id="brandIdParam" />
				<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" 
				id="getBrand"/>  
				<input type="text" name="brandName" id="brandName" value="${brandName}" readonly="readonly" size="60" style="border: 0px;"/>
			</td>
			<th>提报耀点价</th>
	 		<td>
	 			<fmt-rt:formatNumber value="${product.prpsShelfPrice}" pattern="#####0.00" var="prpsShelfPrice"/>
				<input id="prpsShelfPrice" name="prpsShelfPrice" type="text" value="${prpsShelfPrice}"/>
				<br/><span class="txt-rd">【※提报耀点价小数点2位数后无条件舍去】</span>
			</td>
	 	 </tr>
	 	<tr>
	 		<th>选择主档图显示类型</th>
	 		<td>
				<input name="graphicType" type="radio" value="S" <c:if test="${product.graphicType eq 'S'}">checked="checked"</c:if>/>方形图
		    <input name="graphicType" type="radio" value="R" <c:if test="${product.graphicType eq 'R'}">checked="checked"</c:if>/>长形图
		  </td>
	 	</tr>
 		<tr>
			<th>关键字</th>			
			<td colspan="3">
				字词之间的分隔符号请以逗号分隔<br/>
				<textarea name="keyword" cols="80" rows="2">${product.productKeyword}</textarea>
			</td>
	  </tr>
		<tr>
			<th>備注</th>			
			<td colspan="3"><textarea name="memo" cols="80" rows="2">${product.productMemo}</textarea></td>
	  </tr>
		<tr>
			<th>前台显示设定</th>
			<td colspan="3">
				<table class="tb-1" width="100%">
					<thead>
						<tr><th>站首页</th></tr>
					</thead>
					<tbody>
						<tr>
							<td>
								<s:checkbox name="flag04" fieldValue="Y" value="%{flag04}">右侧本周推荐(tab 1)</s:checkbox>
								<s:checkbox name="flag05" fieldValue="Y" value="%{flag05}">右侧新鲜货(tab 2)</s:checkbox>
								<s:checkbox name="flag06" fieldValue="Y" value="%{flag06}">右侧热门话题(tab 3)</s:checkbox>
							</td>
						</tr>
					</tbody>
					<thead>
						<tr><th>分类页第2层以下</th></tr>
					</thead>				
					<tbody>
						<tr>
							<td>
								<s:checkbox name="flag16" fieldValue="Y" value="%{flag16}">馆长推荐</s:checkbox>
							</td>
						</tr>
					</tbody>
				</table>
			</td>
		</tr>	  	  
		<tr>
			<td colspan="4">
				<input type="hidden" name="virtual" value="Y"/>
				<input type="hidden" id="isEndNode" name="isEndNode"/>
				<input type="hidden" id="tempCategoryPath" name="tempCategoryPath" value="${categoryPath}"/>
				<input type="hidden" id="mainCategoryId" name="mainCategoryId" value="${product.mainCategoryID}" />			
				<input type="hidden" name="productId" value="${productId}"/>
				<input type="button" name="submit1" value="储存商品"/>
				<input type="button" onclick="this.form.action='list.do';this.form.submit();" value="Cancel"/>*为必填资料
			</td>
	  </tr>
		<tr>
			<th>* 商品特色</th>			
			<td colspan="3">
				<textarea id="brief" name="brief" cols="60" rows="5">${brief}</textarea>
			</td>
	  </tr>
		<tr>
			<th>* 商品描述</th>			
			<td colspan="3">
				<textarea id="description" name="description" cols="150" rows="30">${description}</textarea>
				<script type="text/javascript">
				CKEDITOR.replace('description',{toolbar : 'product'});
				CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
	  </tr>
		<tr>
			<th>* 规格参数</th>			
			<td colspan="3">
				<textarea id="details" name="details" cols="150" rows="30" >${details}</textarea>
				<script type="text/javascript">
					CKEDITOR.replace('details',{toolbar : 'product'});
					CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
	  </tr>
		<tr>
			<th>购物须知<br/>（若不填会带入该馆预设内容）</th>
			<td colspan="3">
				<textarea id="orderNotice" name="orderNotice" cols="150" rows="30">${orderNotice}</textarea>
				<script type="text/javascript">
				CKEDITOR.replace('orderNotice',{toolbar : 'product'});
				CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
		</tr>
			<tr id="showScmNotice">
				<th>特殊商品购物须知</th>
				<td colspan="3">
					<textarea id="scmNotice" name="scmNotice" cols="150" rows="30">${scmNotice}</textarea>
				</td>
			</tr>
		<tr>
			<td colspan="4">
				<input type="hidden" id="spId" value=""/>
				<input type="hidden" id="spName" value=""/>
				<input type="hidden" id="supplierScm" name="supplierScm"/>
				<input type=button name="submit2" value="储存商品"/>
				<input type="button" onclick="this.form.action='list.do';this.form.submit();" value="Cancel"/>*为必填资料
			</td>
	  </tr>
</table>
</s:form>
<div id="loadingImg" style="display:none;">
	<img src="/images/loading.gif"/>资料载入中,请稍候...
</div>